<%--
  Created by IntelliJ IDEA.
  User: EDY
  Date: 2023-11-01
  Time: 8:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.js"></script>
    <script src="../../js/bootstrap-table.min.js"></script>
    <script src="../../js/bootstrap.bundle.min.js"></script>
    <script src="../../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../js/jquery.form.js"></script>
    <script src="../../js/jquery.validate.js"></script>
    <script src="../../js/messages_zh.js"></script>
    <link rel="stylesheet" href="../../css/bootstrap-table.min.css"></link>
    <link rel="stylesheet" href="../../css/bootstrap.min.css"></link>
    <style>
        #form {
            position: absolute;
            top: 10%;
            bottom: 10%;
            left: 10%;
            right: 10%;
            margin: auto;
        }
    </style>
</head>
<body>
    <table width="100%">
        <tbody>
        <tr height="20">
            <td>
                <span style="color: #0c84ff">您正在做的业务是：生产管理--工序物料设计--工序物料设计单审核</span>
            </td>
        </tr>
        <tr height="20">
            <td align="right">
                <input type="button" onclick="checkOk()" value="确认">
                <input type="button" value="返回" onclick="history.back();">
            </td>
        </tr>
        </tbody>
    </table>
    <div>
        <table width="80%" align="center" border="0" bgcolor="#FFFFFF">
            <tbody>
            <tr>
                <td rowspan="2">
                    <table cellspacing="0" cellpadding="0" width="100%" style="border: #333333 1px solid;">
                        <tbody>
                        <tr>
                            <td colspan="4" height="10">
                                <table width="100%">
                                    <tbody>
                                    <tr>
                                        <td>
                                            <table align="center">
                                                <tbody>
                                                <tr height="20">
                                                    <td align="center" height="5"><font size="4"><b>工序物料设计单</b></font>
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                            <table align="center">
                                                <tbody>
                                                <tr height="20">
                                                    <td align="center" height="5">&nbsp;</td>
                                                </tr>
                                                </tbody>
                                            </table>
                                            <table align="center" id="theObjTable">
                                                <tbody>
                                                <tr height="20px">
                                                    <td align="right" width="12%">
                                                        工序单编号：
                                                    </td>
                                                    <td>
                                                        <input type="text" readonly name="designId" style="outline: none;border: 0px">
                                                    </td>
                                                    <td>
                                                        设计人：
                                                    </td>
                                                    <td>
                                                        <input type="text" name="designer" style="outline: none;width: 100%;border:0px;">
                                                    </td>
                                                </tr>
                                                <tr height="20px">
                                                    <td align="right">
                                                        产品名称：
                                                    </td>
                                                    <td>
                                                        <input type="text" readonly name="productName" style="outline: none;border: 0px">
                                                    </td>
                                                    <td align="left" >
                                                        产品编号：
                                                    </td>
                                                    <td>
                                                        <input type="text" readonly name="productId" style="outline: none;border: 0px">
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                            <table align="center">
                                                <tbody>
                                                <tr height="20">
                                                    <td align="center" height="5">&nbsp;</td>
                                                </tr>
                                                </tbody>
                                            </table>
                                            <table border="1" cellspacing="0" cellpadding="0"
                                                   align="center" id="tableOnlineEdit" style="width: 100%;text-align: center;">
                                                <thead>
                                                <tr height="20" bgcolor="#D2E9FF">
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                                        序号
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">工序名称
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">工序编号
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                                        描述
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                                        工时数
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="16%">
                                                        工时成本小计(元)
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                                        物料成本小计
                                                    </td>
                                                    <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                                        详细
                                                    </td>
                                                </tr>
                                                </thead>
                                            </table>
                                            <table align="center">
                                                <tbody>
                                                <tr height="20">
                                                    <td align="center" height="5">&nbsp;</td>
                                                </tr>
                                                </tbody>
                                            </table>
                                            <table align="center" id="theTable">
                                                <tbody>
                                                <tr height="20px">
                                                    <td align="right" width="10%">工时总成本：
                                                    </td>
                                                    <td width="30%">
                                                        <input name="costPriceSum" readonly style="border: 0px;outline: none">
                                                    </td>
                                                    <td align="right" width="10%">物料总成本：
                                                    </td>
                                                    <td width="30%">
                                                        <input name="moduleCostPriceSum" readonly style="border: 0px;outline: none">
                                                    </td>
                                                </tr>
                                                <tr height="20px">
                                                    <td align="right" width="10%">设计要求：
                                                    </td>
                                                    <td width="30%">
                                                        <input name="procedureDescribe" readonly style="border: 0px;outline: none">
                                                    </td>
                                                </tr>
                                                <tr height="20px">
                                                    <td align="right" width="10%">审核人：
                                                    </td>
                                                    <td width="30%">
                                                        <input type="text" name="checker" value="${sysUsers.loginId}" readonly style="outline: none;width: 100%;border:0px;">
                                                    </td>
                                                    <td align="left" width="10%">审核时间：
                                                    </td>
                                                    <td align="left" width="30%">
                                                        <input name="checkTime" readonly style="border: 0px;outline: none">
                                                    </td>
                                                </tr>
                                                <tr height="20">
                                                    <td align="right" width="9%">审核意见：
                                                    </td>
                                                    <td align="left" colspan="3" width="89%">
                                                        <textarea rows="4" name="checkSuggestion" style="width: 100%"></textarea>
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" nowrap="" width="56">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" nowrap="" height="100"></td>
                            <td></td>
                        </tr>

                        <tr valign="bottom">
                            <td colspan="4" nowrap="" align="center"></td>
                        </tr>

                        <tr>
                            <td colspan="4" nowrap="" align="right"></td>
                        </tr>
                        </tbody>
                    </table>
                </td>
                <td width="1" bgcolor="#ffffff" height="2"></td>
                <td width="1" bgcolor="#ffffff" height="2"></td>
                <td width="1" bgcolor="#ffffff" height="2"></td>
            </tr>
            <tr>
                <td width="1" bgcolor="#333333" height="120"></td>
                <td width="1" bgcolor="#666666" height="120"></td>
                <td width="1" bgcolor="#999999" height="120"></td>
            </tr>
            <tr valign="top" align="right">
                <td colspan="4">
                    <table cellspacing="0" cellpadding="0" align="center" border="0">
                        <tbody>
                        <tr>
                            <td bgcolor="#333333" height="1"></td>
                        </tr>
                        <tr>
                            <td bgcolor="#666666" height="1"></td>
                        </tr>
                        <tr>
                            <td bgcolor="#999999" height="1"></td>
                        </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <form class="modal fade" id="modalform" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content" style="width: 725px;height: 500px;position: absolute;left: -110px;">
                <h6><span style="color: #0c84ff">您正在做的业务是：生产管理--工序物料设计--工序物料设计单审核</span></h6>
                <div class="modal-header">
                    <table width="100%">
                        <tbody>
                        <tr>
                            <td>
                                <table align="center">
                                    <tbody>
                                    <tr height="20">
                                        <td align="center" height="5"><font size="4"><b>工序物料设计单</b></font>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table align="center">
                                    <tbody>
                                    <tr height="20">
                                        <td align="center" height="5">&nbsp;</td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table align="center" id="MDPDTable" width="100%">
                                    <tbody>
                                    <tr height="20px">
                                        <td align="right" width="15%">
                                            设计单编号：
                                        </td>
                                        <td>
                                            <input type="text" readonly name="designId" style="outline: none;border: 0px">
                                        </td>
                                        <td>
                                            工序名称：
                                        </td>
                                        <td>
                                            <input type="text" name="procedureName" style="outline: none;width: 100%;border:0px;">
                                        </td>
                                    </tr>
                                    <tr height="20px">
                                        <td align="right">
                                            登记人：
                                        </td>
                                        <td>
                                            <input type="text" readonly name="register" style="outline: none;border: 0px">
                                        </td>
                                        <td align="left" >
                                            登记时间：
                                        </td>
                                        <td>
                                            <input type="text" readonly name="registerTime" style="outline: none;border: 0px">
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table align="center">
                                    <tbody>
                                    <tr height="20">
                                        <td align="center" height="5">&nbsp;</td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table border="1" cellspacing="0" cellpadding="0"
                                       align="center" id="DesignModuleTable" style="width: 100%;text-align: center;">
                                    <thead>
                                    <tr height="20" bgcolor="#D2E9FF">
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            序号
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            物料名称
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            物料编号
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            描述
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            本工序数量
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="16%">
                                            单位
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            单价（元）
                                        </td>
                                        <td bordercolor="#DEDBD6" align="left" width="12.5%">
                                            小计（元）
                                        </td>
                                    </tr>
                                    </thead>
                                </table>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </form>
    <script>
        function showCostPrice(){
            var sum=0;
            $("#tableOnlineEdit :input[name='moduleSubtotal']").each(function (index,item) {
                sum=parseInt(sum)+parseInt($(item).val())
            })
            $(":input[name='moduleCostPriceSum']").val(sum)
        }
        $(":input[name='checkTime']").val(new Date().toLocaleString())
        $(function () {
            $.post("/MDesignProcedure/showMDesignProcedureById",{id:'${param.id}'},function (data) {
                $.each(data,function (key,value) {
                    if(key=="checker"){
                        return ;
                    }
                    if(key=="checkTime"){
                        return ;
                    }
                    $("input[name="+key+"]").val(value)
                })
            })
            var i=1;
            $.post("/MDesignProcedure/showMDesignProcedureDetailsByParentId",{id:'${param.id}'},function (data) {
                $.each(data,function (index,item) {
                    var tr=$("<tr>" +
                            "<td>"+i+"</td>" +
                            "<td>"+item.procedureName+"</td>" +
                            "<td>"+item.procedureId+"</td>" +
                            "<td>"+item.procedureDescribe+"</td>" +
                            "<td>"+item.labourHourAmount+"</td>" +
                            "<td>"+item.subtotal+"</td>" +
                            "<td><input name='moduleSubtotal' readonly style='border: 0px;outline: none;width: 100px;' value='"+item.moduleSubtotal+"'></td>" +
                            "<td><a href='javascript:void(0)' onclick=rk('"+item.id+"')>"+"详细"+"</a></td>" +
                        "</tr>")
                    i=i+1;
                    $("#tableOnlineEdit").append(tr);
                })
                showCostPrice()
            })
        })
        function checkOk() {
            var id="${param.id}";
            var designId=$("#theObjTable :input[name='designId']").val()
            var designer=$("#theObjTable :input[name=designer]").val();
            var productName=$("#theObjTable :input[name=productName]").val();
            var productId=$("#theObjTable :input[name=productId]").val();
            var costPriceSum=$("#theTable :input[name='costPriceSum']").val()
            var moduleCostPriceSum=$("#theTable :input[name='moduleCostPriceSum']").val()
            var procedureDescribe=$("#theTable :input[name='procedureDescribe']").val()
            var checker=$("#theTable :input[name=checker]").val();
            var checkTime=$("#theTable :input[name=checkTime]").val();
            var checkSuggestion=$("#theTable [name=checkSuggestion]").val();
            var arr={
                id:id,
                designId:designId,
                designer:designer,
                productName:productName,
                productId:productId,
                costPriceSum:costPriceSum,
                moduleCostPriceSum:moduleCostPriceSum,
                procedureDescribe:procedureDescribe,
                checker:checker,
                checkTime:checkTime,
                checkSuggestion:checkSuggestion
            }
            $.ajax({
                url:"/MDesignProcedure/DesignModuleCheckOk",
                type:"post",
                data:JSON.stringify(arr),
                contentType:'application/json',
                dataType:"json",
                success:function (data) {
                    alert(data.msg)
                    if(data.code=='1'){
                        location.href="check_list.jsp";
                    }else{
                        location.href="check_list.jsp";
                    }
                }
            })
        }
        function rk(id) {
            $("#DesignModuleTable tr:not(:first)").remove()
            $.post("/MDesignProcedure/showMDesignProcedureDetailsById",{id:id},function (data){
                $.each(data,function (key,value) {
                    $("#MDPDTable :input[name="+key+"]").val(value)
                })
            })
            $.post("/MDesignProcedure/showProcedureModuleByParentId",{id:id},function (data) {
                $(data).each(function (index,item) {
                    var tr=$("<tr>" +
                        "<td>"+item.detailsNumber+"</td>" +
                        "<td>"+item.productName+"</td>" +
                        "<td>"+item.productId+"</td>" +
                        "<td>"+item.productDescribe+"</td>" +
                        "<td>"+item.amount+"</td>" +
                        "<td>"+item.amountUnit+"</td>" +
                        "<td>"+item.costPrice+"</td>" +
                        "<td>"+item.subtotal+"</td>" +
                        "</tr>")

                    $("#DesignModuleTable").append(tr)
                })
            })
            $("#modalform").modal("show")
        }
    </script>
</form>
</body>
</html>
